package com.kede.app.domain;

import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.io.Serializable;

/**
* @description /
* @author Pr.li
* @date 2023-05-11
**/
@Entity
@Data
@Table(name="sy_transfer_log")
public class TransferLog implements Serializable {
    /**
    * 
    */
    @ApiModelProperty(value = "id")
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    private Integer id;
    /**
    * 用户id
    */
    @ApiModelProperty(value = "用户id")
    @Column(name = "`userid`",nullable = false)
    @NotNull
    private Integer userid;
    /**
    * 关联批次id 商家批次单号
    */
    @ApiModelProperty(value = "关联批次id 商家批次单号")
    @Column(name = "`out_batch_no`",nullable = false)
    @NotBlank
    private String outBatchNo;
    /**
    * 商家明细单号
    */
    @ApiModelProperty(value = "商家明细单号")
    @Column(name = "`out_detail_no`",unique = true,nullable = false)
    @NotBlank
    private String outDetailNo;
    /**
    *  转账金额
    */
    @ApiModelProperty(value = " 转账金额")
    @Column(name = "`transfer_amount`",nullable = false)
    @NotNull
    private BigDecimal transferAmount;
    /**
    * 转账备注
    */
    @ApiModelProperty(value = "转账备注")
    @Column(name = "`transfer_remark`",nullable = false)
    @NotBlank
    private String transferRemark;
    /**
    * openid
    */
    @ApiModelProperty(value = "openid")
    @Column(name = "`openid`",nullable = false)
    @NotBlank
    private String openid;
    /**
    * 明细状态  WAIT_PAY: 待确认。待商户确认, 符合免密条件时, 系统会自动扭转为转账中
PROCESSING:转账中。正在处理中，转账结果尚未明确
SUCCESS:转账成功
FAIL:转账失败
    */
    @ApiModelProperty(value = "明细状态")
    @Column(name = "`detail_status`")
    private String detailStatus;
    /**
    * 明细失败原因
    */
    @ApiModelProperty(value = "明细失败原因")
    @Column(name = "`fail_reason`")
    private String failReason;
    /**
    * 创建时间
    */
    @ApiModelProperty(value = "创建时间")
    @Column(name = "`createtime`")
    private Integer createtime;
    /**
    * 更新时间
    */
    @ApiModelProperty(value = "更新时间")
    @Column(name = "`updatetime`")
    private Integer updatetime;
    /**
    * 应用发起来源 
    */
    @ApiModelProperty(value = "应用发起来源 ")
    @Column(name = "`type`")
    private String type;

    @Transient
    private String username;

    @Transient
    private String userphone;

    public void copy(TransferLog source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
